//package boot.spring.listener;
//
//import java.util.List;
//
//import javax.annotation.Resource;
//
//import org.activiti.engine.HistoryService;
//import org.activiti.engine.TaskService;
//import org.activiti.engine.delegate.DelegateExecution;
//import org.activiti.engine.delegate.ExecutionListener;
//import org.activiti.engine.task.Task;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
//import com.google.common.collect.Lists;
//
//@Component
//public class FlowTakeListener implements ExecutionListener{
//	
///** @Fields serialVersionUID: */
//	
//	private static final Logger log = LoggerFactory.getLogger(FlowTakeListener.class);
//	  	
//	private static final long serialVersionUID = 1L;
// 
//	@Resource
//	private TaskService taskService;
//	
//	@Resource
//	private HistoryService historyService;
//	
//	@Resource(name="applyFormInfoService")
//	private ApplyFormInfoService applyFormInfoService;
//
//	@Override
//	public void notify(DelegateExecution execution) {
//		// TODO Auto-generated method stub
//		// TODO Auto-generated method stub
//				List<MyActivitiTask> myTasks = Lists.newArrayList();
//				log.debug("-------------------------------------over time start--------------------------");
//				//获取超时业务ID
//				//获取超时的流程实例ID
//				//String processInstanceId = delegateExecution.getProcessInstanceId();
//				//获取流程历史数据
//				//HistoricProcessInstance hisProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
//				//获取业务主键ID
//				String businessKey = execution.getProcessInstanceBusinessKey();
//				log.debug("--------------------业务ID------------" + businessKey);
//				//获取需要执行的任务
//				List<Task> tasks = taskService.createTaskQuery().processInstanceBusinessKey(businessKey).list();
//				
//				for(Task task:tasks){
//					MyActivitiTask myTask = new MyActivitiTask();
//					myTask.setBussinessId(Long.parseLong(businessKey));
//					myTask.setCreateDate(task.getCreateTime());
//					myTask.setUserId(Integer.parseInt(task.getAssignee()));
//					myTasks.add(myTask);
//				}
//				
//				this.applyFormInfoService.insertApproveOvertimeRecord(myTasks);
//				
//				Integer approverId = this.applyFormInfoService.selectGradeAdvisorByBusId(Integer.parseInt(businessKey));
//				//设置审批人
//				log.debug("--------------年级主任--------" + approverId);
//				execution.setVariable("userId", approverId);
//	}
//
//}
